<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>

</head>

<body>

    <button data-toggle-id="email">邮箱</button>
    <input type="text" id="email">

    <hr>
    <button data-toggle-id="username">用户</button>
    <input type="text" id="username">

    <hr>

    <div data-toggle-id="abc">hello</div>
    <div id="abc">hello jack</div>

    <script>
        document.onclick = function (e) {
            //获取toggleId的值
            const toggleId = e.target.dataset.toggleId;
            if (toggleId !== undefined) {
                // 通过toggleId的值找对应ID元素 toggleId=>ID
                const el = document.getElementById(toggleId);
                el.hidden = !el.hidden;
            }
        }



    </script>

</body>

</html>